home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <GL/glx.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- static const char* ClassOf(int c)
- {
- switch (c) {
- case StaticGray: return "StaticGray";
- case GrayScale: return "GrayScale";
- case StaticColor: return "StaticColor";
- case PseudoColor: return "PseudoColor";
- case TrueColor: return "TrueColor";
- case DirectColor: return "DirectColor";
- default: return "unknown";
- }
- }
-
- static void DumpGLXProperties(Display *dpy, XVisualInfo *vi)
- {
- int bufferSize, level, rgba, doubleBuffer, stereo, auxBuffers,
- redSize, greenSize, blueSize, alphaSize, depthSize, stencilSize,
- accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize;
-
- glXGetConfig(dpy, vi, GLX_BUFFER_SIZE, &bufferSize);
- glXGetConfig(dpy, vi, GLX_LEVEL, &level);
- glXGetConfig(dpy, vi, GLX_RGBA, &rgba);
- glXGetConfig(dpy, vi, GLX_DOUBLEBUFFER, &doubleBuffer);
- glXGetConfig(dpy, vi, GLX_STEREO, &stereo);
- glXGetConfig(dpy, vi, GLX_AUX_BUFFERS, &auxBuffers);
- glXGetConfig(dpy, vi, GLX_RED_SIZE, &redSize);
- glXGetConfig(dpy, vi, GLX_GREEN_SIZE, &greenSize);
- glXGetConfig(dpy, vi, GLX_BLUE_SIZE, &blueSize);
- glXGetConfig(dpy, vi, GLX_ALPHA_SIZE, &alphaSize);
- glXGetConfig(dpy, vi, GLX_DEPTH_SIZE, &depthSize);
- glXGetConfig(dpy, vi, GLX_STENCIL_SIZE, &stencilSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_RED_SIZE, &accumRedSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_GREEN_SIZE, &accumGreenSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_BLUE_SIZE, &accumBlueSize);
- glXGetConfig(dpy, vi, GLX_ACCUM_ALPHA_SIZE, &accumAlphaSize);
-
- printf(" bufferSize=%d level=%d rgba=%d doubleBuffer=%d stereo=%d\n",
- bufferSize, level, rgba, doubleBuffer, stereo);
- printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
- redSize, greenSize, blueSize, alphaSize);
- printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n",
- auxBuffers, depthSize, stencilSize);
- printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
- accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize);
- }
-
- int main()
- {
- XVisualInfo match, *vi;
- Display *dpy;
- int found;
-
- dpy = XOpenDisplay(0);
- if (!dpy) {
- fprintf(stderr, "Can't connect to display \"%s\"\n", getenv("DISPLAY"));
- return -1;
- }
-
- match.screen = DefaultScreen(dpy);
- vi = XGetVisualInfo(dpy, VisualScreenMask, &match, &found);
- while (--found >= 0) {
- int value;
- glXGetConfig(dpy, vi, GLX_USE_GL, &value);
- if (value) {
- printf("Visual ID: %x depth=%2d class=%s\n",
- vi->visualid, vi->depth, ClassOf(vi->class));
- DumpGLXProperties(dpy, vi);
- }
- vi++;
- }
- return 0;
- }
-